#include<iostream>
#include<queue>

using namespace std ;

const int maxn = 20 ;

char room[maxn][maxn];

int dir[4][2] {
        {-1 , 0},
        {0 , -1},
        {1 , 0},
        {0 , 1}
};

//Wx是行数 ， Hy是列数 ， num是统计可以走的有几个位置
int Wx , Hy , num ;

#define CHECK(x , y) (x < Wx && y < Hy && x >= 0 && y >= 0)

struct node {
    int x ;
    int y ;
};

void BFS(int dx , int dy) {
    num += 1 ;  //起点也可以走
    queue<node> q ;
    node start , next ;
    start.x = dx ;
    start.y = dy ;
    q.push(start) ;
    while(!q.empty()) {
        start = q.front();q.pop();
        for (int i = 0; i < 4; ++i) {
            int newx = start.x + dir[i][0];
            int newy = start.y + dir[i][1];
            next = {newx , newy};
            if(CHECK(newx , newy) && room[newx][newy] == '.'){
                room[newx][newy] = '#';
                num++;
                q.push(next) ;
            }
        }
    }
}


int main() {

    int dx , dy ;
    scanf("%d%d" , &Wx , &Hy);
    for (int i = 0; i < Wx; ++i) {
        for (int j = 0; j < Hy; ++j) {
            scanf("%c" , &room[i][j]);
            if(room[i][j] == '@') {
                dx = i ;
                dy = j ;
            }
        }
    }

    num = 0;
    BFS(dx , dy);
    
    return 0 ;
}